package com.chart.chart.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chart.chart.domian.req.UListReq;
import com.chart.chart.mapper.SysUserOpinionMapper;
import com.chart.chart.service.SysUserOpinionService;
import com.chart.common.core.domain.entity.SysUserOpinion;
import com.chart.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class SysUserOpinionServiceImpl extends ServiceImpl<SysUserOpinionMapper, SysUserOpinion> implements SysUserOpinionService {


    @Autowired
    private SysUserOpinionMapper sysUserOpinionMapper;

    //查询用户意见需求
//    @Override
//    public List<SysUserOpinion> queryList(SysUserOpinion req) {
//
//        String phoneNumber = req.getPhoneNumber();
//        List<SysUserOpinion> sysUserOpinions = sysUserOpinionMapper.queryList(phoneNumber);
//
//
//
//        return sysUserOpinions;
//    }

    @Override
    public List<SysUserOpinion> queryList(SysUserOpinion req) {
        // 获取传入的手机号
        String phoneNumber = req.getPhoneNumber();

        // 根据手机号查询意见列表
        List<SysUserOpinion> sysUserOpinions = sysUserOpinionMapper.queryList(phoneNumber);

        // 遍历查询结果并处理每条记录的图片 URL
        for (SysUserOpinion sysUserOpinion : sysUserOpinions) {
            String imageUrl = sysUserOpinion.getImageUrl();
            if (imageUrl != null && !imageUrl.isEmpty()) {
                // 拆分逗号分隔的图片 URL 字符串并转换为 List
                List<String> imageUrls = Arrays.asList(imageUrl.split(","));
                sysUserOpinion.setImageUrls(imageUrls);
            } else {
                sysUserOpinion.setImageUrls(null); // 如果没有图片，设置为空
            }
        }
        // 返回处理后的意见列表
        return sysUserOpinions;
    }

}
